package com.nhjf.component.task;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import com.nhjf.common.util.Properties.SysProperties;
import com.nhjf.common.util.tools.SpringContextUtil;
import com.nhjf.model.jobDetails.JobDetails;
import com.nhjf.model.postJob.PostJob;
import com.nhjf.pojo.qo.jobDetails.JobDetailsQo;
import com.nhjf.pojo.qo.postJob.PostJobQo;
import com.nhjf.service.jobDetails.JobDetailsService;
import com.nhjf.service.postJob.PostJobService;


/**
 * 
 * @类功能说明：作业过期
 * @类修改者：
 * @版本：V1.0
 *
 */
public class ElectronicCodeTask extends QuartzTask{
	
	/**
	 * 定时检查作业过期
	 */
	@Override
	public void execute() {
		System.out.println("********************************");
		JobDetailsService jobDetailsService = (JobDetailsService)SpringContextUtil.getBean("jobDetailsService");
		JobDetailsQo detailsQo=new JobDetailsQo();
		detailsQo.setSeachPostJob(true);
		detailsQo.setSeachStudent(true);
		detailsQo.setStatus(2);
		List<JobDetails> list= jobDetailsService.queryList(detailsQo);
		for (JobDetails jobDetails : list) {
			if(jobDetails.getUnpaidReason()==null) {
				if(jobDetails.getPostJob().getEndTime().before(new Date())) {
					jobDetails.setUnpaidReason(4);
					jobDetailsService.update(jobDetails);
				}
			}
		}
		
			//		ElectronicCodeBatchService electronicCodeBatchService = (ElectronicCodeBatchService)SpringContextUtil.getBean("electronicCodeBatchService");
			//		try {
			//			//定时任务为0时则开启订单检查
			//			if ("0".equals(SysProperties.getInstance().get("checkElectronicCode"))) {
			//				electronicCodeBatchService.expireElectronicCode();
			//			}
			//		} catch (Exception e) {
			//			e.printStackTrace();
			//		}
		}


	}
